package com.hxd.otc.module.my.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.common.enums.BankType;
import com.hxd.otc.module.my.bean.CurrencyBean;
import com.hxd.otc.module.my.contract.AddBankCardContract;
import com.hxd.otc.module.my.model.BankModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

import java.util.ArrayList;

/**
 * Created by lzy on 2018/6/8 0008.
 * description ${添加收款方式}
 */
public class AddBankCardPresenter extends BasePresenter<AddBankCardContract.View> implements AddBankCardContract.Presenter {

    private final BankModel mModel;

    public AddBankCardPresenter(AddBankCardContract.View view) {
        super(view);
        mModel = BankModel.getInstance();
    }

    @Override
    public void getCurrecies() {
        mModel.getCurrencyList(new BaseObserver<ArrayList<CurrencyBean>>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull ArrayList<CurrencyBean> currencyBeans) {
                mView.updateCurrencies(currencyBeans);
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean<ArrayList<CurrencyBean>>>bindAutoDispose());
    }

    @Override
    public void addBankCard(String payNo, String bankName, String branchBankName, String country, String realName,
                            String supportCurrencyCode, String remark) {
        mModel.addBank(payNo, bankName, branchBankName, country, realName, supportCurrencyCode, new BaseObserver<Object>() {
            @Override
            public void onNext(String msg, Object o) {
                mView.addBankCardSuccess(msg);
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean>bindAutoDispose());
    }

    @Override
    public void start() {
    }
}
